package com.sctvcloud.qingchuan.ui.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.ImageView;

import com.blankj.utilcode.util.ActivityUtils;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.qingchuan.R;
import com.sctvcloud.qingchuan.base.BaseDetailActivity;
import com.sctvcloud.qingchuan.beans.TopicSubBean;
import com.sctvcloud.qingchuan.ui.fragment.SubTopicNewsListFragment;
import com.sctvcloud.qingchuan.ui.utils.TitleUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author suming
 * @date 2020/8/13 15:41
 */
public class SubTopicActivity extends BaseDetailActivity {
    public static final String KEY_DATA = "DATA";

    @BindView(R.id.title_top_layout_edit)
    CustomFontTextView mShareTextView;
    @BindView(R.id.title_top_title)
    CustomFontTextView mTitleTextView;
    @BindView(R.id.title_top_logo)
    ImageView mLogoImageView;

    private TopicSubBean mTopicSubBean;

    public static void start(TopicSubBean bean) {
        Bundle bundle = new Bundle();
        bundle.putParcelable(KEY_DATA, bean);
        ActivityUtils.startActivity(bundle, SubTopicActivity.class);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sub_topic);
        ButterKnife.bind(this);
        mShareTextView.setVisibility(View.INVISIBLE);
        mTitleTextView.setVisibility(View.VISIBLE);
        mLogoImageView.setVisibility(View.GONE);

        Intent intent = getIntent();
        if (intent != null) {
            mTopicSubBean = intent.getExtras().getParcelable(KEY_DATA);
        }
        if (mTopicSubBean != null) {
            mTitleTextView.setText(mTopicSubBean.getSubTopicTitle());

            SubTopicNewsListFragment fragment = new SubTopicNewsListFragment();
            fragment.setTopicData(mTopicSubBean);
            fragment.setViewTitle(false);

            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.container, fragment);
            transaction.commit();

        }
    }

    @OnClick({R.id.title_top_layout_back})
    void onViewClick(View view) {
        onBackPressed();
    }
}
